import 'package:flutter/material.dart';

class ChannelInfo {
  String id;
  String name;
  ChannelInfo({this.id, this.name});
}

class FixedChannel extends StatelessWidget {
  ChannelInfo channelInfo;
  List<ChannelInfo> channel_infos;
  void Function(ChannelInfo) onSelectChannel;
  FixedChannel({this.channelInfo, this.onSelectChannel,this.channel_infos});
  @override
  Widget build(BuildContext context) {
    List<Widget> getChannelInfoNode() {
      return channel_infos.map((e) {
        return Container(
            child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 8.0),
          child: Container(
            width: 70.0,
            child: FlatButton(
                color: channelInfo.id == e.id
                    ? Colors.blueAccent
                    : Colors.blueGrey.withOpacity(0.06),
                shape: StadiumBorder(),
                onPressed: () {
                  onSelectChannel(e);
                },
                child: Text(
                  e.name,
                  style: TextStyle(
                    fontSize: 13,
                    color: channelInfo.id == e.id ? Colors.white : Colors.blue,
                  ),
                )),
          ),
        ));
      }).toList();
    }

    return Container(
      height: 30,
      child: ListView(
        scrollDirection: Axis.horizontal,
        children: getChannelInfoNode(),
      ),
    );
  }
}
